<?php

	// TITLE: Home_owner_asset AUTO MODEL
	// FILE: scaffolding/model/home_owner_asset.php
	// AUTHOR: AUTOGEN
	// CREATED: 2015/04/20 07:49:57
	// DESCRIPTION: 
	// REQUIREMENTS: 

	$createHomeOwnerAsset = function($con, $homeOwnerAsset) {
		$sql = 'INSERT INTO home_owner_asset (id, ho_id, title, description, value) VALUES (';
		$sql .= $home_owner_asset->getId() . ', ';
		$sql .= $home_owner_asset->getHoId() . ', ';
		$sql .= $home_owner_asset->getTitle() . ', ';
		$sql .= $home_owner_asset->getDescription() . ', ';
		$sql .= $home_owner_asset->getValue() . ')';
		$sql .= ')';
		$result = mysqli_query($con, $sql);
		$id = ($result) ? mysqli_insert_id($con) : $result;
		mysqli_close($con);
		return $id;
	};

	$readHomeOwnerAsset = function($con, $id) {
		$sql = 'SELECT * FROM home_owner_asset WHERE id = ' . $id;
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$result = mysqli_fetch_array($results);
			$homeOwnerAsset = new HomeOwnerAsset();
			$homeOwnerAsset->setId(result[0]);
			$homeOwnerAsset->setHoId($dbio->select($readHo(result[1])));
			$homeOwnerAsset->setTitle(result[2]);
			$homeOwnerAsset->setDescription(result[3]);
			$homeOwnerAsset->setValue(result[4]);
		} else {
			$homeOwnerAsset = false;
		}
		return $homeOwnerAsset;
	};

	$updateHomeOwnerAsset = function($con, $homeOwnerAsset) {
		$sql = 'UPDATE home_owner_asset SET ';
		$sql .= 'id = ' . $home_owner_asset->getId() . ', ';
		$sql .= 'ho_id = ' . $home_owner_asset->getHoId() . ', ';
		$sql .= 'title = ' . $home_owner_asset->getTitle() . ', ';
		$sql .= 'description = ' . $home_owner_asset->getDescription() . ', ';
		$sql .= 'value = ' . $home_owner_asset->getValue() ;
		$sql .= 'WHERE id = ' . id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$deleteHomeOwnerAsset = function($con, $id) {
		$sql = 'DELETE FROM home_owner_asset WHERE id = ' . $id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$listHomeOwnerAsset = function($con) {
		$sql = 'SELECT * FROM home_owner_asset';
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$homeOwnerAssets = array();
			while ($result = mysqli_fetch_array($results)) {
				$homeOwnerAsset = new HomeOwnerAsset();
				$homeOwnerAsset->setId(result[0]);
				$homeOwnerAsset->setHoId($dbio->select($readHo(result[1])));
				$homeOwnerAsset->setTitle(result[2]);
				$homeOwnerAsset->setDescription(result[3]);
				$homeOwnerAsset->setValue(result[4]);
				$homeOwnerAssets[] = homeOwnerAsset;
			}// end while
		} else {
			$homeOwnerAssets = false;
		}
		return $homeOwnerAssets;
	};

